package com.briup.mt.Api;

import com.baidu.aip.imageclassify.AipImageClassify;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * @program: mt
 * @description: 百度图像识别
 * @author: charles
 * @create: 2020-12-19 09:49
 **/

public class Baidu {
    //设置APPID/AK/SK
    public static final String APP_ID = "23183354";
    public static final String API_KEY = "ScNx3Ycyzs68sgaMtApzcEcT";
    public static final String SECRET_KEY = "dhjh8Q1DNHMdNH0d0wsTXGEr7xnlhjg2";

    public static void main(String[] args) {
        // 初始化一个AipImageClassify
        AipImageClassify client = new AipImageClassify(APP_ID, API_KEY, SECRET_KEY);

        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);

        // 可选：设置代理服务器地址, http和socket二选一，或者均不设置
        //client.setHttpProxy("proxy_host", proxy_port);  // 设置http代理
        //client.setSocketProxy("proxy_host", proxy_port);  // 设置socket代理

        // 调用接口
        String path = "C:\\Users\\Administrator\\Desktop/1.jpg";
        //String path = "/Users/lichunyu/Desktop/bed_3.jpg";
        JSONObject res = client.advancedGeneral(path, new HashMap<>());
        System.out.println(res.toString(2));

    }
}
